const formatTime = date => {
	let year = date.getFullYear();
	let month = date.getMonth()+1;
	let day = date.getDate();
	let hour = date.getHours();
	let minute = date.getMinutes();
	let second = date.getSeconds();
	return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
}


/**
 * 此方法在 数组顺序对程序功能不影响时可使用
 */
function remove(arr,index){
	arr[index] = arr[arr.length - 1];
	arr.pop();
}


function checkLength(s,len,mes){
	if(s.length>=len) return true;
	
	uni.showToast({
		title:mes+"不能少于"+len+"个字符",
		icon:"error"
	});
	console.log(555);
	return false;
}

function returnUserInfo(data){
	let user = {
		id: data.id,
		token: data.token,
		avatar: data.avatar,
		type: data.type,
		nickName: data.nickName,
		userName: data.userName,
		email: data.email
	}
	return user;
}

function ellipsis(str,len){
	if(str && str.length > len){
		return str.substr(0,len-3) + "...";
	}
	return str;
}


module.exports ={
	remove,
	formatTime,
	checkLength,
	returnUserInfo,
	ellipsis
}